package cn.oschina.controller;

import cn.oschina.annotation.OschinaAnnotation;
import cn.oschina.controller.base.BaseController;
import cn.oschina.entity.User01Entity;
import cn.oschina.entity.UserEntity;
import cn.oschina.service.ProjectService;
import cn.oschina.service.UserService;
import cn.oschina.service.impl.UserServiceImpl01;
import com.fasterxml.jackson.databind.util.JSONPObject;
import com.fasterxml.jackson.databind.util.JSONWrappedObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.View;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @Describe
 * @Author lin
 * @create 2025/2/12 14:40
 */
@Controller
@OschinaAnnotation
public class User01Controller extends BaseController {

    @Autowired
    UserService userService;

    ProjectService projectService;

    static class JSONO extends JSONPObject {

        public JSONO(String function, Object value) {
            super(function, value);
        }

        public String aaaa() {
            return "";
        }
    }

    class User1 extends UserEntity {
    }

    public void test001(com.fasterxml.jackson.databind.util.JSONPObject a) {
    }



    public void test002(UserEntity[] a) {
    }

    public void test005(UserEntity[] a,User01Entity b) {
    }
    List<JSONPObject> b = new ArrayList<>();

    UserEntity ax = new UserEntity();

    //调用父类
    public void callParentMethod() {
        ax.getAge();
        User01Entity u2 = new User01Entity();
        u2.getUsername();
        UserEntity u = new UserEntity();
        UserService u1 = getService();
        test003(u, null);
    }


    /**
     * 这是一个注释
     * @return
     */
    public JSONPObject getObj() {
        return new JSONPObject("", null);
    }

    public Long getInt(long l) {
        return 1L;
    }

    public long getlong() {
        return 1L;
    }

    public UserEntity getUserById(int id) {
        userService.getUserById(1L);
        getUserById02(getA().aaaa(), null);
        return userService.getUserById2(1);
    }

    public UserEntity getUserById(List<Integer> id, Map<String,Integer> b) {
        userService.getUserById2(b.get("1"));
        return userService.getUserById2(id.get(0));
    }

    public ModelAndView getUserById01(List<JSONPObject> id, JSONWrappedObject p) {
        UserService user001;
        user001 = new UserServiceImpl01();
        userService.getUserById2(new Integer(2));
        getService();
        return new ModelAndView((View) userService.getUserById(1L));
    }

    public ModelAndView getUserById02(String id, JSONWrappedObject[] p) {
        List<JSONPObject> a = new ArrayList<>();
        getUserById01(a, null);
        getUserById02(id, p);
        UserService userService = getService();
        long a1 =1 ;
        return new ModelAndView((View) userService.getUserById(a1));
    }

    public ModelAndView getUserById03(JSONPObject id, JSONWrappedObject p) throws InstantiationException, IllegalAccessException {
        UserService userService = UserServiceImpl01.class.newInstance();
        return new ModelAndView((View) userService.getUserById(1L));
    }


    public JSONO getA() {
        return new JSONO(null, null);
    }


    public UserService getService() {
        return new UserServiceImpl01();
    }

    //调用本地方法
    public void callLocalMethod() {
        getUserById(1);
        projectService.getProject();
    }
}

